/*
 * Diego Zamboni Latance 			344990
 * Fellipe Augusto Ruiz de Souza 	344796
 * 
 */
package ast;

public class AssignCommand extends Statement {

	@Override
	public void genC(PW pw) {
		// empty
	}

	@Override
	public void genKrakatoa(PW pw) {
		pw.printIdent("");
		if (isThis) {
			pw.print("this.");
		} else {
			if (classe != null) {
				pw.print(classe.getKrakatoaName() + ".");
			}
		}
		var.genKrakatoa(pw);
		pw.print(" = ");
		expr.genKrakatoa(pw, false);
		pw.print(";\n");
	}

	public AssignCommand(Variable var, Expr expr) {
		this.var = var;
		this.expr = expr;
		this.isThis = false;
		this.classe = null;
	}

	public AssignCommand(Variable var, Expr expr, ClassDec classe) {
		this.var = var;
		this.expr = expr;
		this.isThis = false;
		this.classe = classe;
	}

	public AssignCommand(Variable var, Expr expr, boolean isThis) {
		this.var = var;
		this.expr = expr;
		this.isThis = true;
	}

	private Variable var;
	boolean isThis;
	private Expr expr;
	ClassDec classe;

}
